<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="../template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html" 
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://xmlns.jcp.org/jsf/core">
    <ui:define name="corpo">
        <div class="page-header">
            <h1><small>Relatórios - Log de acesso a fatura</small></h1>
        </div>
        <ol class="breadcrumb">
            <li>Home</li>
            <li>Relatórios</li>
            <li class="active">Log de Fatura</li>
        </ol>
        <h:form id="form">
            <p:dataTable id="tabela" var="p" value="#{controllerHistoricoFatura.listaDM}" emptyMessage="Nenhum log de acesso a fatura nos registros..."
                         paginator="true" rows="10"  paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">
                <p:column headerText="Fatura" styleClass="centralizar-texto">
                    <p:commandLink update=":form" oncomplete="PF('dlg').show();" title="Detalhe">
                        <!--<span class="ui-icon ui-icon-search"></span>-->
                        <h:outputText value="#{p.fatura.id}"/>
                        <f:setPropertyActionListener value="#{p.fatura}" target="#{controllerHistoricoFatura.faturaSelecionada}" />
                    </p:commandLink>
                </p:column>
                <p:column headerText="Data de acesso" styleClass="centralizar-texto">
                    <h:outputText value="#{p.data_acesso}">
                        <f:convertDateTime pattern="dd/MM/YYYY 'às' HH:mm:ss" timeZone="America/Araguaina"/>
                    </h:outputText>
                </p:column>
                <p:column headerText="Endereço IP" styleClass="centralizar-texto">
                    <h:outputText value="#{p.endereco_ip}"/>
                </p:column>
            </p:dataTable>
            <p:dialog header="Fatura #{controllerHistoricoFatura.faturaSelecionada.id}" widgetVar="dlg" modal="false" height="270" width="500" resizable="false">
                <table class="table table-bordered table-striped table-hover ">
                    <tr>
                        <th class="centralizar-texto">Atributo</th>
                        <th class="centralizar-texto">Valor</th>
                    </tr>
                    <tr>
                        <td class="direita-texto"> 
                            <h:outputText value="Hash: " />
                        </td>
                        <td>
                            <h:outputText value="#{controllerHistoricoFatura.faturaSelecionada.md5}" />
                        </td>
                    </tr>
                    <tr>
                        <td class="direita-texto">
                            <h:outputText value="Mês de referência: "/>
                        </td>
                        <td>
                            <h:outputText value="#{controllerHistoricoFatura.faturaSelecionada.data_mes_referencia}">
                                <f:convertDateTime pattern="MM/YYYY"/>
                            </h:outputText>
                        </td>
                    </tr>
                    <tr>
                        <td class="direita-texto">
                            <h:outputText value="Usuário: " />
                        </td>
                        <td>
                            <h:outputText value="#{controllerHistoricoFatura.faturaSelecionada.usuario.login}" />
                        </td>
                    </tr>
                    <tr>
                        <td class="direita-texto">
                            <h:outputText value="Criado: " />
                        </td>
                        <td>
                            <h:outputText value="#{controllerHistoricoFatura.faturaSelecionada.data_criacao_fatura}">
                                <f:convertDateTime pattern="dd/MM/YYYY 'às' HH:mm:ss" timeZone="America/Araguaina"/>
                            </h:outputText>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <a href="financeiro_fatura.jsf" class="btn btn-default btn-sm">Ver faturas</a>
                        </td>
                    </tr>
                </table>                
            </p:dialog>
        </h:form>
    </ui:define>
</ui:composition>